﻿using System;
using System.IO;
using System.Windows;

namespace TemplateGenerator.Logic {
	public static class ExceptionHandler {

		private static readonly string FilePath = Environment.CurrentDirectory + "\\ErrorLog.txt";

		public static void WriteException(Exception ex) {
			// Check if file exists
			if (!File.Exists(FilePath)) File.Create(FilePath);

			File.WriteAllText(FilePath, DateTime.Now + ": " + ex.Message + Environment.NewLine);
			if (ex.InnerException != null) {
				WriteException(ex.InnerException);
			}
		}

		public static void NotifyAboutException(Exception ex) {
			MessageBox.Show(ex.Message, "Failure", MessageBoxButton.OK);
		}
		
	}
}
